package com.zhl.controller;

import akka.actor.ActorRef;
import akka.actor.ActorSystem;
import akka.actor.Props;
import com.zhl.actor.HelloActor;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;

/**
 * Created by Administrator on 2018/12/29.
 */
@Controller
public class IndexController {

    @Autowired
    ActorSystem actorSystem;

    @RequestMapping("/actor/actor")
    public void actor() {

        for (int i = 1;i <= 50;i++) {
            //调用构造函数初始化
            ActorRef actorRef = actorSystem.actorOf(Props.create(HelloActor.class, "HelloActor" + i), "HelloActor" + i);
            //执行,可以传递参数,对象等
            actorRef.tell("报数:",ActorRef.noSender());

        }


    }

}
